<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="static/bootstrap-3.4.1-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="static/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
    <script src="static/js/jquery.min.js"></script>
    <title>Title</title>
</head>
<body>

</body>
</html>
<script>
  var person={
    'name':'张小明',
    'age':20,
    'foods':['苹果','香蕉','橘子','葡萄'],
    'pets':[
      {
        'petName':'大黄',
        'petType':'dog'
      }
    ]
  }

  console.log(person.name)
  console.log(person.foods[0])
  console.log(person.pets[0].petName)     //获取对象属性值

  var personStr=JSON.stringify(person)
  console.log(personStr)                    //转换为json字符并在控制台打印

  var person1=JSON.parse(personStr);        //转换json为对象,在控制台打印
  console.log(person1)
</script>